from rest_framework import serializers
from .models import BrowsingHistory
from apps.chefs.serializers import ChefSerializer

class BrowsingHistorySerializer(serializers.ModelSerializer):
    chef = ChefSerializer(read_only=True)
    distance = serializers.SerializerMethodField()
    
    class Meta:
        model = BrowsingHistory
        fields = ['id', 'chef', 'viewed_at', 'distance']
        read_only_fields = ['id', 'viewed_at']
    
    def get_distance(self, obj):
        # 这里可以根据用户位置计算实际距离
        return None